package com.kk.jtq.monijiantingqi;

/**
 * the class of Plan1ThreadsAndJUC
 *
 * <p>
 * .
 *
 * @author little_lunatic
 * @date 2023-03-09
 */
public class Test {
    public static void main(String[] args) {
        // 1.创建事件源
        Person person = new Person();
        // 2.事件源注册监听
        person.registerListener(new PersonListener() {
            @Override
            public void doEat(PersonEvent personEvent) {
                Person person1 = personEvent.getPerson();
                System.out.println(person1 + "吃完准备睡");
            }

            @Override
            public void doSleep(PersonEvent personEvent) {
                Person person1 = personEvent.getPerson();
                System.out.println(person1 + "睡完准备吃");
            }
        });


        person.eat();
        person.sleep();
    }
}
